Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Fix #15781
Backport #15782 to 7.x

Summary

Examples

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #15781 by ensuring the overwriteImmutable option is properly propagated from bulkWrite operations through the casting pipeline to the handleImmutable function. This allows users to explicitly override immutable field protection when using bulkWrite operations, which was previously not possible.

Key Changes:

  • Modified handleImmutable to accept and respect the overwriteImmutable option
  • Updated castUpdate to pass options through to handleImmutable calls
  • Modified castBulkWrite to pass overwriteImmutable from operation options to castUpdate for both updateOne and updateMany operations

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/model.updateOne.test.js Adds test case verifying that overwriteImmutable: true allows updating immutable createdAt field via bulkWrite
lib/helpers/query/handleImmutable.js Adds options parameter to function signature and checks for options.overwriteImmutable to bypass immutable protection
lib/helpers/query/castUpdate.js Updates both handleImmutable call sites to pass the options parameter
lib/helpers/model/castBulkWrite.js Passes overwriteImmutable option from bulkWrite operations to castUpdate for updateOne and updateMany; also passes timestamps option to applyTimestampsToUpdate for granular timestamp control

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gaastonsr
Copy link

Tysm!

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that we can't use overwriteImmutable in TypeScript, pushing a fix for 7.x and master as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants